$(document).ready(function(){
	titleSearch.onload();
})
var titleSearch=(function(){
	var init=function(){}
	return{
		onload:function(){
			var curSeg=titleSearch;
			init();
			curSeg.hdInput();
			curSeg.clickP();
		},
		/*搜索下拉框显示和隐藏*/
		hdInput:function(){
			var data = [
                  {
			        "MKXK_MC": "申报纳税",
			        "SJ_MKXKID": 0,
			        "MKXKID": 1,
			        "SSY": "01",
			        "SHOW_ORDER": 1,
			        "XMFL_DM": "80",
			        "JDFL_DM": "01",
			        "F_ICON":"nav_sbns"
			    }, {
			        "MKXK_MC": "涉税办理",
			        "SJ_MKXKID": 0,
			        "MKXKID": 2,
			        "MKXK_URL": "",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "01",
			       "F_ICON":"nav_ssbl"
			    }, {
			        "MKXK_MC": "发票办理",
			        "SJ_MKXKID": 0,
			        "MKXKID": 3,
			        "MKXK_URL": "",
			        "SSY": "01",
			        "SHOW_ORDER": 5,
			        "XMFL_DM": "80",
			        "JDFL_DM": "01",
			        "F_ICON":"nav_fpbl"
			    }, {
			        "MKXK_MC": "银税互动",
			        "SJ_MKXKID": 0,
			        "MKXKID": 5,
			        "MKXK_URL": "",
			        "SSY": "01",
			        "SHOW_ORDER": 9,
			        "XMFL_DM": "80",
			        "JDFL_DM": "01",
			         "F_ICON":"nav_yshd"
			    }, {
			        "MKXK_MC": "社保费缴纳",
			        "SJ_MKXKID": 0,
			        "MKXKID": 6,
			        "MKXK_URL": "server/platform/mmgl/index.jsp",
			        "SSY": "01",
			        "SHOW_ORDER": 99,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03",
			        "F_ICON":"nav_sbfjn"
			    }, 
			     {
			        "MKXK_MC": "法律救济",
			        "SJ_MKXKID": 0,
			        "MKXKID": 7,
			        "MKXK_URL": "server/platform/mmgl/index.jsp",
			        "SSY": "01",
			        "SHOW_ORDER": 999,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03",
			        "F_ICON":"nav_fljj"
			    },
			    {
			        "MKXK_MC": "申报清单",
			        "SJ_MKXKID": 1,
			        "MKXKID": 101,
			         "MKXK_URL": "bsdt/sbqd/sbqd.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    }, {
			        "MKXK_MC": "税源信息采集",
			        "SJ_MKXKID": 1,
			        "MKXKID": 102,
					"SSY": "01",
			        "MKXK_URL": "bsdt/xxcj/syxxcj.html",
			        "SSY": "01",
			        "SHOW_ORDER": 3,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    }, 
			    {
			        "MKXK_MC": "税费缴纳",
			        "SJ_MKXKID": 1,
			        "MKXKID": 103,
			        "SSY": "01",
			        "SHOW_ORDER": 3,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    },
			      {
			        "MKXK_MC": "逾期申报",
			        "SJ_MKXKID": 1,
			        "MKXKID": 104,
			         "MKXK_URL": "bsdt/xxcj/syxxcj.html",
			        "SSY": "01",
			        "SHOW_ORDER": 3,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    },
			     {
			        "MKXK_MC": "申报作废",
			        "SJ_MKXKID": 1,
			        "MKXKID": 105,
			         "MKXK_URL": "bsdt/xxcj/syxxcj.html",
			        "SSY": "01",
			        "SHOW_ORDER": 3,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    },
			    {
			        "MKXK_MC": "申报更正",
			        "SJ_MKXKID": 1,
			        "MKXKID": 106,
			         "MKXK_URL": "bsdt/xxcj/syxxcj.html",
			        "SSY": "01",
			        "SHOW_ORDER": 3,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    },
			    {
			        "MKXK_MC": "海关稽查",
			        "SJ_MKXKID": 1,
			        "MKXKID": 107,
			         "MKXK_URL": "bsdt/xxcj/syxxcj.html",
			        "SSY": "01",
			        "SHOW_ORDER": 3,
			        "XMFL_DM": "80",
			        "JDFL_DM": "02"
			    },
			    
			    {
			        "MKXK_MC": "税务登记",
			        "SJ_MKXKID": 2,
			        "MKXKID": 201,
			        "MKXK_URL": "main3.html",
			        "SSY": "01",
			        "SHOW_ORDER": 1,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    }, {
			        "MKXK_MC": "认定管理",
			        "SJ_MKXKID": 2,
			        "MKXKID": 202,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    }, 
			    {
			        "MKXK_MC": "税收优惠",
			        "SJ_MKXKID": 2,
			        "MKXKID": 203,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    },
			    {
			        "MKXK_MC": "申报征收",
			        "SJ_MKXKID": 2,
			        "MKXKID": 204,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    },
			    {
			        "MKXK_MC": "税收证明",
			        "SJ_MKXKID": 2,
			        "MKXKID": 205,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    },
			    {
			        "MKXK_MC": "跨区域涉税事项报验管理",
			        "SJ_MKXKID": 2,
			        "MKXKID": 206,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    },
			    {
			        "MKXK_MC": "涉税专业服务",
			        "SJ_MKXKID": 2,
			        "MKXKID": 207,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    },
			    {
			        "MKXK_MC": "涉税事项套餐",
			        "SJ_MKXKID": 2,
			        "MKXKID": 208,
			        "MKXK_URL": "main4.html",
			        "SSY": "01",
			        "SHOW_ORDER": 4,
			        "XMFL_DM": "80",
			        "JDFL_DM": "03"
			    },
			    {
			        "MKXK_MC": "票种核定",
			        "SJ_MKXKID": 3,
			        "MKXKID": 301,
			        "MKXK_URL": "main3.html",
			        "SSY": "01",
			        "SHOW_ORDER": 1,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    }, {
			        "MKXK_MC": "发票领用",
			        "SJ_MKXKID": 3,
			        "MKXKID": 302,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			    {
			        "MKXK_MC": "发票代开",
			        "SJ_MKXKID": 3,
			        "MKXKID": 303,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			    {
			        "MKXK_MC": "发票验旧缴销",
			        "SJ_MKXKID": 3,
			        "MKXKID": 304,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			     {
			        "MKXK_MC": "发票挂失、损毁报告",
			        "SJ_MKXKID": 3,
			        "MKXKID": 305,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			     {
			        "MKXK_MC": "增值税税控系统专用设备变更发行",
			        "SJ_MKXKID": 3,
			        "MKXKID": 306,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			    {
			        "MKXK_MC": "开具红字增值税专用发票",
			        "SJ_MKXKID": 3,
			        "MKXKID": 307,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			    {
			        "MKXK_MC": "增值税专用发票最高开票限额审批",
			        "SJ_MKXKID": 3,
			        "MKXKID": 308,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			     {
			        "MKXK_MC": "购票人维护",
			        "SJ_MKXKID": 3,
			        "MKXKID": 309,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			        "SSY": "01",
			        "SHOW_ORDER": 2,
			        "XMFL_DM": "80",
			        "JDFL_DM": "045"
			    },
			      {
			        "MKXK_MC": "我的贷款",
			        "SJ_MKXKID": 5,
			        "MKXKID": 501,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			    {
			        "MKXK_MC": "我的申请",
			        "SJ_MKXKID": 5,
			        "MKXKID": 502,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			      {
			        "MKXK_MC": "社会保险信息登记",
			        "SJ_MKXKID": 6,
			        "MKXKID": 601,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			       {
			        "MKXK_MC": "注销社保信息登记",
			        "SJ_MKXKID": 6,
			        "MKXKID": 602,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			    {
			        "MKXK_MC": "变更社保信息登记",
			        "SJ_MKXKID": 6,
			        "MKXKID": 603,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			    {
			        "MKXK_MC": "单位社会保险费日常申报(全责)",
			        "SJ_MKXKID": 6,
			        "MKXKID": 604,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			     {
			        "MKXK_MC": "社会保险费申报缴纳",
			        "SJ_MKXKID": 6,
			        "MKXKID": 605,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			     {
			        "MKXK_MC": "社会保险费查询",
			        "SJ_MKXKID": 6,
			        "MKXKID": 606,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			       {
			        "MKXK_MC": "违法处置",
			        "SJ_MKXKID": 7,
			        "MKXKID": 701,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    },
			    {
			        "MKXK_MC": "纳税担保申请",
			        "SJ_MKXKID": 7,
			        "MKXKID": 702,
			        "MKXK_URL": "server3/platform/qxgl/jsgl/qxjs_index.html",
			       
			    }
                ];     
            function pjDiv(){
            	$("#titleSearch").css("display","block");
                var inputVal=$("#titleInput").val();
                var html='';
                if(inputVal){
                	for(var i=0;i<data.length;i++){
	            		if(data[i].SJ_MKXKID!==0){
	            			var str=data[i].MKXK_MC;
	            			var strUrl=data[i].MKXK_URL;
	            			var strId=data[i].MKXKID;
	            			if(str.indexOf(inputVal,0)!="-1"){
	            				html+='<p data-url="'+strUrl+'" data-id="'+strId+'">'+str+'</p>'
	            			}
	            		}
	                }
                	$("#titleSearch").html(html); 
                }else{
                	$("#titleSearch").css("display","none");
                }
            }
            var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
		    //判断是否chorme浏览器
		    if (userAgent.indexOf("Chrome") > -1){
				document.getElementById('titleInput').oninput=function(){
					pjDiv()
				}
		    } 
		    //判断是否IE浏览器
		    if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !userAgent.indexOf("Opera") > -1) {
		        document.getElementById('titleInput').attachEvent('onpropertychange',function(){    
	                pjDiv()       
	           });
		    }    
		},
		/*点击下拉选项*/
		clickP:function(){
            $("#titleSearch").on("click","p",function(e){
            	var pHtml=$(e.target).html();
            	$("#titleInput").val(pHtml);
            	var pUrl=$(e.target).data("url");
            	$("#titleSearch").css("display","none");
            	var pId=$(e.target).data("id");
            	apearDiv=true;
            	var as=$('#main_iframe').contents().find(".page-tabs-content a");
            	var $likeA="";//路径一样的a
            	for(var i=0;i<as.length;i++){
            		var aUrl=$(as[i]).data("id");
            		if(pUrl==aUrl){
            			$likeA=$(as[i]);
            		}
            	}
            	if($likeA){
            		$(as).removeClass("active");
            		$likeA.addClass("active");
            	}else{
            		$(as).removeClass("active");
            		var html='<a href="javascript:;" class="active menuTab" data-id="' + pUrl + '"><label class="nav_text">' + pHtml + '</label> <span class="btn_close"></span></a>';
            		$('#main_iframe').contents().find(".page-tabs-content").append(html);
            		var str1 = '<iframe class="LRADMS_iframe" id="iframe' + pId + '" name="iframe' + pId + '"  width="100%" height="100%" src="' + pUrl + '" frameborder="0" data-id="' + pUrl + '" seamless></iframe>';
		            $('#main_iframe').contents().find(".mainContent").find('iframe.LRADMS_iframe').hide();
		            $('#main_iframe').contents().find(".mainContent").append(str1);
		           
            	}
            });	
		}
	}
})()
